<template>
	<view class="CanvasBox">
		<navbar :title="i18n.qbgl"></navbar>
		<view class="pt15">
			<view class="fcc mx15 bor5 py20 px15 bg-theme">
				<image :src="userInfo.avatar" mode="aspectFill" class="block50"></image>
				<view class="white ml11">
					<view class="f20">{{ userInfo.walletName }}</view>
					<view class="fcc mt12 f13 ">
						<view class=" w450">邀请码：{{ userInfo.inviteCode}}</view>
						<image src="../../static/uesr/wcopy.png" class="block10 ml2" @click="copy(userInfo.inviteCode)"></image>
					</view>
				</view>
				<!-- <view class="blue text--center px10 py6 f11 border" @click="pushPage('./modifyName')">
					<text>{{ i18n.xgnc }}</text>
				</view> -->
			</view>
		</view>
		<view class="box w690 auto white">
			<view class=" border2 py18 fsb " @click="pushPage('./modifyPws')">
				<view class="f13 flex-text">
					{{i18n.xgmm}}
				</view>
				<image src="../../static/uesr/right.png" mode="" class="block w6 h11"></image>
			</view>
			<view class=" border2 py18 fsb " @click="beifen('memo')">
				<view class="f13 flex-text">
					{{i18n.bfzjc}}
				</view>
				<image src="../../static/uesr/right.png" mode="" class="block w6 h11"></image>
			</view>
			<view class=" border2 py18 fsb "  @click="beifen('priKey')">
				<view class="f13 flex-text">
					{{ i18n.dcsy }}
				</view>
				<image src="../../static/uesr/right.png" mode="" class="block w6 h11"></image>
			</view>
			<!-- <view class=" border2 py18 fsb " @click="Tologin()">
				<view class="f13 flex-text">
					退出账号
				</view>
				<image src="../../static/user/right.png" mode="" class="block w6 h11"></image>
			</view> -->
			<view class=" border2 py18 fsb " @click="pushPage('./account')">
				<view class="f13 flex-text">
					{{i18n.qhqb}}
				</view>
				<image src="../../static/uesr/right.png" mode="" class="block w6 h11"></image>
			</view>
			<view class="bg-theme py12 color-white f14 text--center bor5 mt30"  @click="Tologin()">
				{{i18n.tczh}}
			</view>
		</view>
		<pay :show="payShow" @close="payCloseFunc" @finish="payNow" ref="payword"></pay>
	</view>
</template>

<script>
import pay from '../../components/payPassword/pay_Password.vue';
export default {
	components: { pay },
	data() {
		return {
			payShow: false,
			Mark: false,
			address:'',
			pws:'',
			exType:'',
		};
	},
	computed: {
		i18n() {
			return this.$t('user');
		}
	},
	onLoad() {
	},
	onShow() {
		this.$refs.payword.close();
		this.getUser();
	},
	methods: {
		payCloseFunc() {
			this.payShow = false;
		},
		beifen(ind){
			this.exType = ind
			this.payShow = !this.payShow
		},
		async payNow(e) {
			let params = {
				passworld: e,
				phoneId:this.UID,
				type: this.exType
			};
			let { data } = await this.$http.post('user.exportMemoOrPrikey', params, { isAuth: true, tipConfig: { isLoading: true } });
			this.payShow = false;
			if(this.exType=='memo'){
				this.pushPage('/pages/my/mnemonic?key=' + data);
			}else{
				this.pushPage('/pages/my/privatekey?key=' + data);
			}
		},
		Tologin() {
			uni.removeStorage({
				key: 'userInfo',
				success: function(res) {}
			});
			uni.removeStorage({
				key: 'token',
				success: function(res) {
					uni.reLaunch({
						url: '../login/index'
					});
				}
			});
		},
		async Submit(){
			if(this.address==''){
				uni.showToast({
					title:this.$t('tips').dztips,
					icon:'none'
				})
				return false
			}
			if(this.pws==''){
				uni.showToast({
					title:this.$t('tips').mmbwk,
					icon:'none'
				})
				return false
			}
			let params = {
				oldAddress:this.address,
				oldPassword:this.pws
			}
			let { data } = await this.$http.post('user.getOldUserInfo', params, { isAuth: true, tipConfig: { isLoading: true } });
			uni.showToast({
				title:this.$t('tips').success
			})
			this.Mark = false
			this.address = ''
			this.pws = ''
			setTimeout(()=>{
				this.getUser();
			},800)
		},
		getDeviceInfo(){
			let that = this
			plus.device.getInfo({
				success:function(e){
					that.UID = e.uuid
				},
				fail:function(e){
					that.UID = e.uuid
				}
			});
		}
	}
};
</script>

<style lang="less">
.border {
	border: 2rpx solid #00b3ff;
	border-radius: 24rpx;
}
.w450 {
	width: 450rpx;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.w484 {
	width: 484rpx;
	word-wrap: break-word;
}
.hei {
	color: #434345;
}
.w512 {
	width: 512rpx;
}
.input {
	border: 2rpx solid #dadadb;
	border-radius: 8rpx;
	line-height: 96rpx;
}
.tips {
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	z-index: 99;
	width: 596rpx;
	background: #ffffff;
	border-radius: 16px;
}
</style>
